package com.yumingjiang.common.util;


import lombok.NonNull;

import java.util.Objects;

/**
 * @description:
 * @author: John
 * @version: Precondition.java, v1.0 2024年12月30日 04:43
 */
public class Precondition {

    public static void checkStrNonNull(String str){
        if (null!=str&& !str.trim().isEmpty()){
            throw new NullPointerException();
        }
    }

    public static void checkNotNull(Object o){
        if (Objects.nonNull(o)){
            throw new NullPointerException();
        }
    }

    public static void checkArgument(@NonNull Boolean expression){
        if (!expression){
            throw new IllegalArgumentException();
        }
    }

    public static void checkArgument(@NonNull Boolean expression,@NonNull String errorMsg){
        if (!expression){
            throw new IllegalArgumentException(errorMsg);
        }
    }
}